package com.xzzz.common.wechat;


import com.xzzz.common.cache.redis.RedisConstant;

/**
 * @author xzzz
 *
 */
public final class WxConstant {

    /**
     * 微信小程序CODE获取session请求
     *
     * <p><p><a href='https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html'>微信官方文档地址</a>
     * <p>API地址示例: https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
     */
    public static final String AUTH_CODE2SESSION_URL = "https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code";
    /**
     * code本地缓存
     */
    public static final String AUTH_CODE_KEY = RedisConstant.CACHE_PREFIX_WITH + "wechat:auth_code:";
    /**
     * 过期时间,分钟,5分钟
     */
    public static final Integer AUTH_CODE_KEY_TIMEOUT_SECONDS = 5;


    /**
     * 微信公众号CODE获取session请求,OAuth2.0 授权登录
     *
     * <p><p><a href='https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_Login/Development_Guide.html'>微信官方文档地址</a>
     * API地址: https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code
     */
    public static final String AUTH_CODE2OAUTH2_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
    /**
     * code本地缓存
     */
    public static final String AUTH_CODE_OAUTH2_KEY = RedisConstant.CACHE_PREFIX_WITH + "wechat:auth_code:oauth2:";
    /**
     * 过期时间,分钟,10分钟
     */
    public static final Integer AUTH_CODE_OAUTH2_KEY_TIMEOUT_SECONDS = 10;


    /**
     * 微信公众号ACCESS_TOKEN获取TICKET
     *
     * <p><p><a href='https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Vendor_API_List.html'>微信官方文档地址</a>
     * <p>API地址: https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=wx_card
     */
    public static final String ACCESS_TOKEN2TICKET_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi";
    /**
     * code本地缓存
     */
    public static final String ACCESS_TOKEN2TICKET_KEY = RedisConstant.CACHE_PREFIX_WITH + "wechat:access_token:ticket:";
    /**
     * 过期时间,分钟,120分钟
     */
    public static final Integer ACCESS_TOKEN2TICKET_KEY_TIMEOUT_SECONDS = 120;


    /**
     * 统一授权码请求
     * <p><p><a href='https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html'>微信官方文档地址</a>
     * <p>API地址: https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
     */
    public static final String AUTH_GET_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s&";
    public static final String ACCESS_TOKEN_KEY = RedisConstant.CACHE_PREFIX_WITH + "wechat:access_token:";


    /**
     * 微信统一消息发送
     * DOC地址: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/uniform-message/uniformMessage.send.html#method-http
     * API地址: https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN
     */
    public static final String MSG_UNIFORMMESSAGE_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN";


    /**
     * 大量小程序码
     * DOC地址: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.getUnlimited.html
     * API地址: https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN
     */
    public static final String WECHAT_CODE_UNLIMITED_URL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=%s";


}
